export default function(sequelize, DataTypes) {
  return sequelize.define('user', {
    id: {
      autoIncrement: true,
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "主键 用户id"
    },
    user_name: {
      type: DataTypes.STRING(20),
      allowNull: false,
      comment: "用户名"
    },
    is_company: {
      type: DataTypes.TINYINT,
      allowNull: true,
      defaultValue: 0,
      comment: "是否是公司用户 0不是 1是"
    },
    email: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: "邮箱",
      unique: "uni_email"
    },
    create_time: {
      type: DataTypes.CHAR(13),
      allowNull: false,
      comment: "创建时间"
    },
    mobile: {
      type: DataTypes.STRING(20),
      allowNull: true,
      comment: "手机号",
      unique: "uni_mobile"
    },
    invitation_code: {
      type: DataTypes.CHAR(6),
      allowNull: false,
      comment: "6位邀请码"
    },
    inviter_id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      comment: "邀请者id"
    }
  }, {
    sequelize,
    tableName: 'user',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
      {
        name: "uni_email",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "email" },
        ]
      },
      {
        name: "uni_mobile",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "mobile" },
        ]
      },
    ]
  });
};
